<template>
	<div class="page-wrap">
		<div class="page-inner">
			<div class="page-table-ctx-wrap">
				<!-- 控制器 -->
				<div class="actions-box">
					<div class="control-box">
						<div class="control-left">
							<div class="control-item">
								<el-button type="primary" @click="doAdd()">
									添加
								</el-button>
							</div>
						</div>
						<div class="control-right">
							<!-- <div class="action-item">
                <el-input v-model="keyword" clearable placeholder="请输入关键词">
                  <el-button slot="append" size="small" icon="el-icon-search" @click="doSearch()">
                  </el-button>
                </el-input>
              </div> -->
						</div>
					</div>
				</div>
				<!-- 控制器 -->

				<!-- 渲染表格 -->
				<div class="table-view">
					<w_table ref="w_table" @emitTable="emitTable" />
				</div>
				<!-- 渲染表格 -->
				<div class="table-util">
					<div class="util-left">
						<!-- 批量选择 -->
					</div>
					<div class="util-right">
						<div class="pagi-item">
							<w_pagination v-if="tableData.length" :total="total" :pagination="pagination"
								@size-change="onSizeChange" @current-change="onCurrentChange" />
						</div>
					</div>
				</div>
			</div>
		</div>


		<w_form_modal ref="w_form_modal" @confirm="confirmFormSubmit" />

		<china_express_form_modal ref="china_express_form_modal" @confirm="confirmFormSubmit" />
	</div>
</template>

<script>
import china_express_form_modal from '@/components/market/express/china_express_form_modal.vue'


import page_config from "@/constant/market/express/china-express.js";
import page_mixin from "@/mixins/page_mixin.js";
export default {
	name: "china-express",
	mixins: [page_mixin],
	components: {
		china_express_form_modal
	},
	data() {
		return {
			page_config
		};
	},
	computed: {

	},
	watch: {},
	created() {

	},
	mounted() {

	},
	methods: {
		doAdd() {
			this.$refs.china_express_form_modal.init();
		},
		doRowEdit(row) {
			this.$refs.china_express_form_modal.init(row);
		},

		format_list_data(list) {
			console.log(list);
			list.forEach(v => {
				let info = ''
				if (v.rules) {
					try {
						let rule_list = JSON.parse(v.rules)
						let rule_text_arr = []
						rule_list.forEach(v => {
							rule_text_arr.push(`基础数量(单位重量)为${v.base}，运费${v.basePrice}元，每增加${v.addNum}数量(单位重量)，需增加运费${v.addPrice}元，生效地区${v.areaNames}，备注：${v.content}；`)
						})
						info = rule_text_arr.join('。')
					} catch (e) {
						//TODO handle the exception
					}
				}
				v.cus_rules = info;

			})
		},
	},
};
</script>

<style scoped lang="less">
// /deep/ .el-table table {
//   width: 100% !important;

//   thead {
//     th.el-table__cell {
//       background: #f8f8f8;
//       color: #000;
//     }
//   }
// }


.page-table-ctx-wrap {
	background: #fff;
	padding: 20px;
	border-radius: 6px;
}

// 新增
.control-box {
	.flex-between();

	.control-left {
		.flex();

		.control-item {
			margin-right: 10px;
		}
	}

	.control-right {
		.flex();

		.action-item {
			margin-left: 10px;
		}
	}
}

.table-view {
	margin-top: 20px;
	margin-bottom: 20px;
}


// 表格工具栏
.table-util {
	.flex-between();

	.util-left {
		.flex();
		min-width: 100px;

		.util-items {
			.flex();

			.item {
				margin-right: 10px;
			}
		}
	}

	.util-right {}
}
</style>